<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var isValidBST = function (root) {
      let arr = [];
      const buildArr = (root) => {
        if (root) {
          buildArr(root.left);
          arr.push(root.val);
          buildArr(root.right);
        }
      }
      buildArr(root);
      for (let i = 1; i < arr.length; ++i) {
        if (arr[i] <= arr[i - 1])
          return false;
      }
      return true;
    };
    console.log(isValidBST([2, 1, 3]));
  </script>
</body>

</html>